﻿<%@ Page Language="C#" MasterPageFile="~/Management/ManagementMasterPage.master"
    AutoEventWireup="true" Inherits="Management_Product_ProductCategoryList" Title="逸品--管理端"
    CodeBehind="ProductCategoryList.aspx.cs" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphContent" runat="Server">
    <table>
        <tr>
            <td valign="top">
                <h1>
                    总分类</h1>
                <div>
                    <asp:ListView ID="lvSupCategory" runat="server" DataKeyNames="CategoryId,Name" OnItemCommand="lvSupCategory_ItemCommand">
                        <LayoutTemplate>
                            <table border="1" cellspacing="0">
                                <tr>
                                    <th>
                                        #
                                    </th>
                                    <th>
                                        名称
                                    </th>
                                    <th>
                                        子分类数量
                                    </th>
                                    <th>
                                        图片
                                    </th>
                                    <th>
                                        其他
                                    </th>
                                </tr>
                                <asp:PlaceHolder ID="itemPlaceholder" runat="server" />
                                <tr>
                                    <td>
                                        <asp:Button ID="btnNew" runat="server" CommandName="OnNew" Text="新增" />
                                    </td>
                                </tr>
                            </table>
                        </LayoutTemplate>
                        <EmptyDataTemplate>
                            <asp:Button ID="btnNew" runat="server" CommandName="OnNew" Text="新增" />
                        </EmptyDataTemplate>
                        <ItemTemplate>
                            <tr>
                                <td>
                                    <%# Container.DataItemIndex+1 %>
                                </td>
                                <td>
                                    <asp:LinkButton ID="btnSubCategory" runat="server" CommandName="OnSubCategory" CommandArgument='<%# Eval("CategoryId") %>'><%# Eval("Name") %></asp:LinkButton>
                                </td>
                                <td>
                                    <%# Eval("SubCategories.Count") %>
                                </td>
                                <td>
                                    <asp:Image runat="server" ID="imagePicture" ImageUrl='<%#Eval("PictureUrl") %>' />
                                </td>
                                <td>
                                    <%--<asp:Button ID="btnEditPic" runat="server" Text="编辑图片" CommandName="OnEditPic" CommandArgument='<%# Eval("CategoryId") %>' />--%>
                                    <asp:Button ID="btnEdit" runat="server" Text="编辑" CommandName="OnEdit" CommandArgument='<%# Eval("CategoryId") %>' />
                                    <asp:Button ID="btnDelete" runat="server" Text="删除" CommandName="OnDelete" CommandArgument='<%# Eval("CategoryId") %>' OnClientClick="return confirm('确定要删除该产品类别吗?');" />
                                    <asp:Button ID="btnUp" runat="server" Text="∧" CommandName="OnUp" CommandArgument='<%# Eval("CategoryId") %>' />
                                    <asp:Button ID="btnDown" runat="server" Text="∨" CommandName="OnDown" CommandArgument='<%# Eval("CategoryId") %>' />
                                </td>
                            </tr>
                        </ItemTemplate>
                        <InsertItemTemplate>
                            <tr>
                                <td>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtName" runat="server" Text='<%# Bind("Name") %>' />
                                </td>
                                <td>
                                </td>
                                <td>
                                    <asp:FileUpload ID="categoryPic" runat="server" />
                                </td>
                                <td>
                                    <asp:Button ID="btnInsert" runat="server" CommandName="OnInsert" Text="添加" />
                                    <asp:Button ID="btnCancel" runat="server" Text="取消" CommandName="OnCancel" CommandArgument='<%# Eval("CategoryId") %>' />
                                </td>
                            </tr>
                        </InsertItemTemplate>
                        <EditItemTemplate>
                            <tr>
                                <td>
                                    <%# Container.DataItemIndex+1 %>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtName" runat="server" Text='<%# Eval("Name") %>' />
                                </td>
                                <td>
                                    <%# Eval("SubCategories.Count") %>
                                </td>
                                <td>
                                    <asp:FileUpload ID="categoryPic" runat="server" />
                                </td>
                                <td>
                                    <asp:Button ID="btnSave" runat="server" Text="确定" CommandName="OnUpdate" CommandArgument='<%# Eval("CategoryId") %>' />
                                    <asp:Button ID="btnCancel" runat="server" Text="取消" CommandName="OnCancel" CommandArgument='<%# Eval("CategoryId") %>' />
                                </td>
                            </tr>
                        </EditItemTemplate>
                    </asp:ListView>
                </div>
                <asp:HiddenField ID="hfCategoryId2" runat="server" />
                <%--<cc1:ModalPopupExtender ID="mpeModify2" runat="server" BackgroundCssClass="ModalBackground"
                    CancelControlID="btnCancel2" PopupControlID="pnlModify2" TargetControlID="btnCrap" />
                <asp:Panel ID="pnlModify2" Style="display: none;" BackColor="AliceBlue" runat="server">
                    <div>
                        <asp:HiddenField ID="hfCategoryId2" runat="server" />
                    </div>
                    <div>
                        <asp:FileUpload ID="fuCategoryPicture2" runat="server" />
                        <asp:HiddenField ID="hfFilePath2" runat="server" />
                    </div>
                    <div>
                    </div>
                    <div>
                        <asp:Button ID="btnSubmit2" runat="server" Text="确定" OnClick="btnSubmit2_Click" />
                        <asp:Button ID="btnCancel2" runat="server" Text="取消" />
                    </div>
                </asp:Panel>--%>
                <asp:HiddenField ID="hfSupCategoryId" runat="server" />
            </td>
            <td valign="top">
                <!----------------------------------------------子分类----------------------------------------------------------------->
                <h1>
                    子分类</h1>
                <div>
                    <asp:HiddenField ID="hfSubCategoryId" runat="server" />
                    <asp:ListView ID="lvSubCategory" runat="server" DataKeyNames="CategoryId,Name" OnItemCommand="lvSubCategory_ItemCommand">
                        <LayoutTemplate>
                            <table border="1" cellspacing="0">
                                <tr>
                                    <th>
                                        #
                                    </th>
                                    <th>
                                        名称
                                    </th>
                                    <th>
                                        该类别商品数
                                    </th>
                                    <th>
                                        图片
                                    </th>
                                    <th>
                                        其他
                                    </th>
                                </tr>
                                <asp:PlaceHolder ID="itemPlaceholder" runat="server" />
                                <tr>
                                    <td colspan="4">
                                        <asp:Button ID="btnNew" runat="server" CommandName="OnNew" Text="新增" />
                                    </td>
                                </tr>
                            </table>
                        </LayoutTemplate>
                        <EmptyDataTemplate>
                            <asp:Button ID="btnNew" runat="server" CommandName="OnNew" Text="新增" />
                        </EmptyDataTemplate>
                        <ItemTemplate>
                            <tr>
                                <td>
                                    <%# Container.DataItemIndex+1 %>
                                </td>
                                <td>
                                    <%--<a id="A1" href='<%# "~/Management/Product/ProductList.aspx?CID=" + Eval("CategoryId") %>'
                                        runat="server">
                                        <%# Eval("Name") %></a>--%>
                                    <asp:LinkButton ID="btnSubCategory" runat="server" CommandName="OnSubCategory" CommandArgument='<%# Eval("CategoryId") %>'><%# Eval("Name") %></asp:LinkButton>
                                </td>
                                <td>
                                    <%# this.GetProductCount(new Guid(Eval("CategoryId").ToString())) %>
                                </td>
                                <td>
                                    <asp:Image runat="server" ID="imagePicture" ImageUrl='<%#Eval("PictureUrl") %>' />
                                </td>
                                <td>
                                    <asp:Button ID="btnEdit" runat="server" Text="编辑" CommandName="OnEdit" CommandArgument='<%# Eval("CategoryId") %>' />
                                    <asp:Button ID="btnDelete" runat="server" Text="删除" CommandName="OnDelete" OnClientClick="return confirm('确定要删除该产品类别吗？');" CommandArgument='<%# Eval("CategoryId") %>' />
                                    <asp:Button ID="btnUp" runat="server" Text="∧" CommandName="OnUp" CommandArgument='<%# Eval("CategoryId") %>' />
                                    <asp:Button ID="btnDown" runat="server" Text="∨" CommandName="OnDown" CommandArgument='<%# Eval("CategoryId") %>' />
                                </td>
                            </tr>
                        </ItemTemplate>
                        <InsertItemTemplate>
                            <tr>
                                <td>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtName" runat="server" Text='<%# Bind("Name") %>' />
                                </td>
                                <td>
                                </td>
                                <td>
                                    <asp:Button ID="btnInsert" runat="server" CommandName="OnInsert" Text="添加" />
                                    <asp:Button ID="btnCancel" runat="server" Text="取消" CommandName="OnCancel" CommandArgument='<%# Eval("CategoryId") %>' />
                                </td>
                            </tr>
                        </InsertItemTemplate>
                        <EditItemTemplate>
                             <tr>
                                <td>
                                    <%# Container.DataItemIndex+1 %>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtName" runat="server" Text='<%# Eval("Name") %>' />
                                </td>
                                <td>
                                    <%# Eval("SubCategories.Count") %>
                                </td>
                                <td>
                                </td>
                                <td>
                                    <asp:Button ID="btnSave" runat="server" Text="确定" CommandName="OnUpdate" CommandArgument='<%# Eval("CategoryId") %>' />
                                    <asp:Button ID="btnCancel" runat="server" Text="取消" CommandName="OnCancel" CommandArgument='<%# Eval("CategoryId") %>' />
                                </td>
                            </tr>
                        </EditItemTemplate>
                    </asp:ListView>
<%--                    <asp:Button ID="btnCrap" runat="server" Text="Button" Style="display: none" />
                    <cc1:ModalPopupExtender ID="mpeModify" runat="server" BackgroundCssClass="ModalBackground"
                        CancelControlID="btnCancel" PopupControlID="pnlModify" TargetControlID="btnCrap" />
                    <asp:Panel ID="pnlModify" Style="display: none;" BackColor="AliceBlue" runat="server">
                        <div>
                            名称：<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
                            <asp:HiddenField ID="hfCategoryId" runat="server" />
                        </div>
                        <div>
                            <asp:FileUpload ID="fuCategoryPicture" runat="server" />
                            <asp:HiddenField ID="hfFilePath" runat="server" />
                        </div>
                        <div>
                            总分类：<uc1:CategoryCascadingDropDown ID="ddlSupCategory" runat="server" ShowLv2Category="True"
                                ShowLv3Category="False" TopCategoryName="Category_L" />
                        </div>
                        <div>
                            <asp:Button ID="btnSubmit" runat="server" Text="确定" OnClick="btnSubmit_Click" />
                            <asp:Button ID="btnCancel" runat="server" Text="取消" />
                        </div>
                    </asp:Panel>--%>
                </div>
            </td>
            <td valign="top">
                <h1>
                    三级分类
                </h1>
                <asp:HiddenField ID="hfThirdCategoryId" runat="server" />
                <asp:ListView ID="lvThirdCategory" runat="server" 
                    DataKeyNames="CategoryId,Name" OnItemCommand="lvThirdCategory_ItemCommand">
                        <LayoutTemplate>
                            <table border="1" cellspacing="0">
                                <tr>
                                    <th>
                                        #
                                    </th>
                                    <th>
                                        名称
                                    </th>
                                    <th>
                                        该类别商品数
                                    </th>
                                    <th>
                                        图片
                                    </th>
                                    <th>
                                        其他
                                    </th>
                                </tr>
                                <asp:PlaceHolder ID="itemPlaceholder" runat="server" />
                                <tr>
                                    <td colspan="4">
                                        <asp:Button ID="btnNew" runat="server" CommandName="OnNew" Text="新增" />
                                    </td>
                                </tr>
                            </table>
                        </LayoutTemplate>
                        <EmptyDataTemplate>
                            <asp:Button ID="btnNew" runat="server" CommandName="OnNew" Text="新增" />
                        </EmptyDataTemplate>
                        <ItemTemplate>
                            <tr>
                                <td>
                                    <%# Container.DataItemIndex+1 %>
                                </td>
                                <td>
                                    <a id="A1" href='<%# "~/Management/Product/ProductList.aspx?CID=" + Eval("CategoryId") %>'
                                        runat="server">
                                        <%# Eval("Name") %></a>
                                </td>
                                <td>
                                    <%# this.GetProductCount(new Guid(Eval("CategoryId").ToString())) %>
                                </td>
                                <td>
                                    <asp:Image runat="server" ID="imagePicture" ImageUrl='<%#Eval("PictureUrl") %>' />
                                </td>
                                <td>
                                    <asp:Button ID="btnEdit" runat="server" Text="编辑" CommandName="OnEdit" CommandArgument='<%# Eval("CategoryId") %>' />
                                    <asp:Button ID="btnDelete" runat="server" Text="删除" CommandName="OnDelete" OnClientClick="return confirm('确定要删除该产品类别吗？');" CommandArgument='<%# Eval("CategoryId") %>' />
                                    <asp:Button ID="btnUp" runat="server" Text="∧" CommandName="OnUp" CommandArgument='<%# Eval("CategoryId") %>' />
                                    <asp:Button ID="btnDown" runat="server" Text="∨" CommandName="OnDown" CommandArgument='<%# Eval("CategoryId") %>' />
                                </td>
                            </tr>
                        </ItemTemplate>
                        <InsertItemTemplate>
                            <tr>
                                <td>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtName" runat="server" Text='<%# Bind("Name") %>' />
                                </td>
                                <td>
                                </td>
                                <td>
                                    <asp:Button ID="btnInsert" runat="server" CommandName="OnInsert" Text="添加" />
                                    <asp:Button ID="btnCancel" runat="server" Text="取消" CommandName="OnCancel" CommandArgument='<%# Eval("CategoryId") %>' />
                                </td>
                            </tr>
                        </InsertItemTemplate>
                        <EditItemTemplate>
                             <tr>
                                <td>
                                    <%# Container.DataItemIndex+1 %>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtName" runat="server" Text='<%# Eval("Name") %>' />
                                </td>
                                <td>
                                    <%# Eval("SubCategories.Count") %>
                                </td>
                                <td>
                                </td>
                                <td>
                                    <asp:Button ID="btnSave" runat="server" Text="确定" CommandName="OnUpdate" CommandArgument='<%# Eval("CategoryId") %>' />
                                    <asp:Button ID="btnCancel" runat="server" Text="取消" CommandName="OnCancel" CommandArgument='<%# Eval("CategoryId") %>' />
                                </td>
                            </tr>
                        </EditItemTemplate>
                    </asp:ListView>
            </td>
            <!--新增//////////////////////////////////////////////////////-->
            <!--end-->
        </tr>
    </table>
</asp:Content>
